package com.gwcd.myapplication;

import android.content.Context;
import android.content.Intent;

import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;

import com.gwcd.myapplication.tools.aos.NetworkUtil;
import com.gwcd.myapplication.ui.SeActivity;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;

/**
 * Instrumented test, which will execute on an Android device.
 *
 * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
 */
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
    @Test
    public void useAppContext() {
        // Context of the app under test.
        Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
        assertEquals("com.gwcd.myapplication", appContext.getPackageName());

        NetworkUtil.sContext = InstrumentationRegistry.getInstrumentation().getTargetContext();

        assertEquals("816", NetworkUtil.getSsid());
    }

    public void mainActivity() {
        Intent intent = new Intent();
        intent.putExtra("handle", 2);
        try {
            InstrumentationRegistry.getInstrumentation().newActivity(getClass().getClassLoader(),
                    SeActivity.class.getName(), intent);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        }
    }
}